﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;

namespace AutumnEngine
{
    public class SpriteNode : Node
    {

        string text;
        Texture2D _text;
        protected Texture2D Texture2D
        {
            get { return _text; }
        }
        protected virtual void ChangedTexture()
        {

        }
        public string Texture
        {
            get { return text; }
            set
            {
                text = value;
                reloadTexture();
                ChangedTexture();
            }
        }
        public SpriteNode(string texture)
        {
            text = texture;
            reloadTexture();
            Origin = Vector2.Zero;
            Color = Color.White;
            _rot = 0f;
            Scale = new Vector2(1f);
        }
       
        public Color Color
        {
            get;
            set;
        }
        

        void reloadTexture()
        {
            _text = Engine.Modules.TextureManager.GetTexture(text);
        }

        public virtual Vector2 Origin
        {
            get;
            set;
        }

        public virtual Vector2 Scale
        {
            get;
            set;
        }

        public override void Draw()
        {
            Engine.SpriteBatch.Draw(_text, this.Position, null, Color, Rotation, Origin, Scale, SpriteEffects.None, 0f);
            base.Draw();
        }
        float _rot;
        public virtual float Rotation
        {
            get { return _rot; }
            set { _rot = value; }
        }
    }
}
